package top.soulblack.purchasesale.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import top.soulblack.purchasesale.model.Supplier;

import java.util.List;

/**
 * create by 小川
 */

@Mapper
public interface SupplierMapper {

    int deleteById(Integer id);

    int insert(Supplier record);

    int insertSelective(Supplier record);

    Supplier selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(Supplier record);

    int updateByPrimaryKey(Supplier record);

    @Select("select * from supplier order by sort")
    List<Supplier> selectAll();

    @Insert("insert into supplier (name,mobile_phone, phone, mail, principal,debt,status,sort,fax,bank_account,bank_number" +
            ",open_person,discount,url,address,remark ) values (#{name}, #{mobilePhone}, #{phone}, #{mail}, #{principal}, 0, #{status}" +
            ", #{sort}, #{fax}, #{bankAccount}, #{bankNumber}, #{openPerson}, #{discount}, #{url}, #{address},#{remark})")
    void addSupplier(Supplier supplier);

    @Select("select count(*) from supplier where name = #{name}")
    int existSupplier(String name);

    @Select("select * from supplier where name = #{name}")
    List<Supplier> selectForName(@Param("name") String name);
}
